package com.sunny.excel.dto;

import java.util.Objects;

/**
 * @Author:shucq
 * @Description:
 * @Date 2019/10/28 15:50
 */
public class Tuple2<V, W> implements Comparable{
    public final V _1;
    public final W _2;

    public Tuple2(V v, W w) {
        _1 = v;
        _2 = w;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        Tuple2<?, ?> tuple2 = (Tuple2<?, ?>) o;

        if (!Objects.equals(_1, tuple2._1))
            return false;
        return Objects.equals(_2, tuple2._2);

    }

    @Override
    public int hashCode() {
        int result = _1 != null ? _1.hashCode() : 0;
        result = 31 * result + (_2 != null ? _2.hashCode() : 0);
        return result;
    }

    @Override
    public int compareTo(Object o) {
        Tuple2 tuple2 = (Tuple2) o;
        return (this._1 == null ? "0" : this._1.toString()).compareTo(tuple2._1 == null ? "0" : tuple2._1.toString());
    }
}
